********************************************************************************
*																			   *
*						Sir! I'd Rather Go to School Sir!					   *
*																			   *
*								 Mahdi Majbouri								   *
*																			   *
*									 Figures								   *
*																			   *
*									6-6-2023								   *
*																			   *
********************************************************************************


********************************************************************************
**  Figures for sole sons
********************************************************************************

use "census11-all.dta", clear

keep if sons==1
keep if age >= 20

keep if fage>=fage18 & fage18>=threshold - 9 & fage18<=threshold + 10 & ///
		father_ed !=. & mom_ed != . & fage !=. & mage !=.

sort fa
by fa: egen mcollbu = mean(college_plus) if relate==3 & son == 1 & sons == 1 ///
	& fage>=fage18 & urban == 2
egen mcollegebu = tag(mcollbu)
		
	
twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(lfitci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lfitci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Sole Son's Father") ///
		ytitle("College attendance") title("Linear fit")  note("") saving("ly.eps", replace)

twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(qfitci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(qfitci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Sole Son's Father") ///
		ytitle("College attendance") title("Quadratic fit")  note("") saving("qy.eps", replace)

twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(lpolyci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lpolyci college_plus fage18 if relate==3 & son == 1 & sons == 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Sole Son's Father") ///
		ytitle("College attendance") title("Polynomial fit")  note("") saving("py.eps", replace)

graph combine "ly.eps" "qy.eps" ///
"py.eps", ycommon ///
graphregion(color(white)) rows(1) cols(3) xsize(12) ysize(4) iscale(*1.5)


graph export "solesons.pdf", replace





********************************************************************************
**  Figures for sisters of sole sons
********************************************************************************

/*
use "census11-all.dta", clear

keep if fage>=fage18 & fage18>=threshold - 9 & fage18<=threshold + 10 & ///
		father_ed !=. & mom_ed != . & fage !=. & mage !=.

*/

by fa: egen mcollgu = mean(college_plus) if relate==3 & female == 1 & ///
	sons == 1 & fage>=fage18 & urban == 2
egen mcollegegu = tag(mcollgu)

twoway ///
(scatter mcollgu fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(lfitci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lfitci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1.2)) xtitle("Age of the Sisters' Father") ///
		ytitle("College attendance") title("Linear fit")  note("") saving("gly.eps", replace)
	
twoway ///
(scatter mcollgu fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(qfitci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(qfitci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1.2)) xtitle("Age of the Sisters' Father") ///
		ytitle("College attendance") title("Quadratic fit") note("") saving("gqy.eps", replace)
	
twoway ///
(scatter mcollgu fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(lpolyci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lpolyci college fage18 if relate==3 & female == 1 & sons == 1 & fage>=fage18 & age<25 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1.2)) xtitle("Age of the Sisters' Father") ///
		ytitle("College attendance") title("Polynomial fit") note("") saving("gpy.eps", replace)
		

graph combine "gly.eps" "gqy.eps" ///
"gpy.eps", ycommon ///
graphregion(color(white)) rows(1) cols(3) xsize(12) ysize(4) iscale(*1.5)
*title("Discontinuity in College Attendance for Sole Sons' Sisters") ///	

graph export "solesonssisters.pdf", replace
	

	

********************************************************************************
**  Figures for sons in multiple-son households
********************************************************************************

use "census11-all.dta", clear

keep if fage>=fage18 & fage18>=threshold - 9 & fage18<=threshold + 10

by fa, sort: egen mcollbu = mean(college_plus) if relate==3 & son == 1 & sons > 1 & fage>=fage18 & urban == 2
egen mcollegebu = tag(mcollbu)
		
	
twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(lfitci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lfitci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Son's Father") ///
		ytitle("College attendance") title("Linear fit")  note("") saving("lmsy.eps", replace)


twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(qfitci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(qfitci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Son's Father") ///
		ytitle("College attendance") title("Quadratic fit")  note("") saving("qmsy.eps", replace)


twoway ///
(scatter mcollbu fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & urban == 2 & mcollegebu, mcolor(gs3) ) ///
(lpolyci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lpolyci college_plus fage18 if relate==3 & son == 1 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Son's Father") ///
		ytitle("College attendance") title("Polynomial fit")  note("") saving("pmsy.eps", replace)

graph combine "lmsy.eps" "qmsy.eps" ///
"pmsy.eps", ycommon ///
graphregion(color(white)) rows(1) cols(3) xsize(12) ysize(4) iscale(*1.5)


graph export "sons-in-multsonHH.pdf", replace



********************************************************************************
**  Figures for daughters in multiple-son households
********************************************************************************

use "census11-all.dta", clear

keep if fage>=fage18 & fage18>=threshold - 9 & fage18<=threshold + 10

sort fa
		
by fa: egen mcollgu = mean(college_plus) if relate==3 & son == 0 & sons > 1 & fage>=fage18 & urban == 2
egen mcollegegu = tag(mcollgu fage18)

	
twoway ///
(scatter mcollgu fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(lfitci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lfitci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Daughter's Father") ///
		ytitle("College attendance") title("Linear fit")  note("") saving("lmsgy.eps", replace)


twoway ///
(scatter mcollgu fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(qfitci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(qfitci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Daughter's Father") ///
		ytitle("College attendance") title("Quadratic fit")  note("") saving("qmsgy.eps", replace)


twoway ///
(scatter mcollgu fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & urban == 2 & mcollegegu, mcolor(gs3) ) ///
(lpolyci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==1 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lpolyci college_plus fage18 if relate==3 & son == 0 & sons > 1 & fage>=fage18 & t==0 & urban == 2, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) xtitle("Age of the Daughter's Father") ///
		ytitle("College attendance") title("Polynomial fit")  note("") saving("pmsgy.eps", replace)

graph combine "lmsgy.eps" "qmsgy.eps" ///
"pmsgy.eps", ycommon ///
graphregion(color(white)) rows(1) cols(3) xsize(12) ysize(4) iscale(*1.5)
	

graph export "daughters-in-multsonHH.pdf", replace	
	
	
	
********************************************************************************
*********************************  THE END *************************************
********************************************************************************
